package oj;

/**
 * @author 郝文雪
 * @date 2022/8/3 23:50
 * @Description Test
 */
public class LC392 {
    public boolean isSubsequence(String s, String t) {
        char[] sc=s.toCharArray();
        char[] tc=t.toCharArray();
        int[][] dp=new int[sc.length+1][tc.length+1];
        for(int i=1;i<=sc.length;i++){
            for(int j=1;j<=tc.length;j++){
                if(sc[i-1]==tc[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=Math.max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
        int len=dp[sc.length][tc.length];
        if(len==sc.length){
            return true;
        }
        return false;
    }
}
